package com.huawang.mdesign.model.service.controller;

import com.huawang.business.constants.ErrorCode;
import com.huawang.business.constants.ErrorLevelEnum;
import com.huawang.business.constants.ParamErrorConstants;
import com.huawang.business.constants.SystemConstants;
import com.huawang.business.dto.AddModelDTO;
import com.huawang.business.dto.CommonPropertyVo;
import com.huawang.business.dto.DeleteModelDTO;
import com.huawang.business.dto.PropertyConfig;
import com.huawang.business.util.ValidateDataUtil;
import com.huawang.business.vo.CheckValidPropertyValueVo;
import com.huawang.business.vo.CopyResultVo;
import com.huawang.business.vo.InstanceVo;
import com.huawang.business.vo.ModelResultVo;
import com.huawang.core.semantics.entity.script.ElementType;
import com.huawang.mdesign.model.service.config.WebLogIgnore;
import com.huawang.mdesign.model.service.dto.*;
import com.huawang.mdesign.model.service.vo.*;
import com.huawang.mdesign.model.service.dto.nameRule.NamingRuleInfo;
import com.huawang.mdesign.model.service.dto.propertymerge.PropertyMergeDTO;
import com.huawang.mdesign.model.service.dto.propertymerge.PropertyMergePreviewVo;
import com.huawang.mdesign.model.service.inter.ModelLibraryService;
import com.huawang.mdesign.model.service.inter.ModelService;
import com.huawang.mdesign.model.service.vo.selectelementitem.SelectAffectElementItem;
import com.huawang.mdesign.model.service.vo.selectelementitem.SelectElementItem;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

@Tag(name = "模型")
@RestController
@RequestMapping("/model")
@Validated
public class ModelController {
    private final ModelService modelService;

    @Autowired
    private ModelLibraryService modelLibraryService;

    public ModelController(ModelService modelService) {
        this.modelService = modelService;
    }

    @Operation(summary = "新增模型")
    @PostMapping("/add")
    public BaseResponse<ModelResultVo> add(@Valid @RequestBody AddModelDTO addModelDto) {
        ModelResultVo resultIds = modelService.addModel(addModelDto);
        return BaseResponse.success(resultIds);
    }

    @Operation(summary = "批量新增")
    @PostMapping("/batchAdd")
    public BaseResponse<ModelResultVo> batchAdd(@Valid @RequestBody BatchAddModelDTO dto) {
        ModelResultVo resultIds = modelService.batchAdd(dto);
        return BaseResponse.success(resultIds);
    }

    @Operation(summary = "删除模型")
    @PostMapping("/deleteByIds")
    public BaseResponse<ModelResultVo> deleteByIds(@Valid @RequestBody DeleteModelDTO deleteModelDto) {
        ModelResultVo resultIds = modelService.deleteByIds(deleteModelDto);
        return BaseResponse.success(resultIds);

    }

    @Operation(summary = "查询模型创建来源")
    @PostMapping("/fetchFrom")
    public BaseResponse<Map<String, Integer>> fetchFrom(@Valid @RequestBody QueryModelDTO dto) {
        return BaseResponse.success(modelService.fetchFrom(dto.getProjectId(), dto.getInstanceIds()));
    }

    @Operation(summary = "查询模型")
    @GetMapping("/query")
    public BaseResponse<InstanceVo> query(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                          @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.query(projectId, instanceId));
    }

    @Operation(summary = "查询instance中子节点")
    @GetMapping("/queryChildren")
    public BaseResponse<List<InstanceVo>> queryChildren(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                        @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.queryChildren(projectId, instanceId));

    }

    @Operation(summary = "查询多个模型")
    @PostMapping("/queryByIds")
    public BaseResponse<List<InstanceVo>> queryByIds(@Valid @RequestBody QueryModelDTO queryModelDto) {
        ValidateDataUtil.outOfIndex(queryModelDto.getInstanceIds());
        return BaseResponse.success(modelService.queryByIds(queryModelDto.getProjectId(),
                queryModelDto.getInstanceIds()));
    }

    @Operation(summary = "查询模型到根包的路径的模型列表")
    @PostMapping("/fetchProfilePathToModel")
    public BaseResponse<List<InstanceVo>> fetchProfileParentPackages(@Valid @RequestBody QueryModelDTO queryModelDto) {
        return BaseResponse.success(modelService.fetchProfileParentPackages(queryModelDto.getProjectId(),
                queryModelDto.getInstanceIds()));
    }

    @Operation(summary = "递归查询包下的所有包信息")
    @GetMapping("/fetchAllPackages")
    public BaseResponse<List<String>> fetchAllPackages(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                       @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.fetchAllPackages(projectId, instanceId));
    }

    @Operation(summary = "递归获取模型下的需求")
    @GetMapping("/reqTree")
    /**@Deprecated
     * 接口废弃
     */
    public BaseResponse<Boolean> fetchReqTree(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                              @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.error(10001, "数据为空", "数据为空", ErrorLevelEnum.INFO);
    }

    @Operation(summary = "查询模型属性列表")
    @WebLogIgnore
    @GetMapping("/queryPropertyList")
    public BaseResponse<List<PropertyConfig>> queryPropertyList(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                                @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId,
                                                                Integer displayLevel) {
        return BaseResponse.success(modelService.queryPropertyListBatch(projectId, instanceId, displayLevel));
    }

    @Operation(summary = "批量更新模型属性值使用：查询多个模型的共同属性")
    @PostMapping("/queryMultiCommonProperty")
    public BaseResponse<List<CommonPropertyVo>> queryMultiCommonProperty(@Valid @RequestBody QueryMultiCommonPropertyDTO dto) {
        return BaseResponse.success(modelService.queryMultiCommonProperty(dto));
    }

    @Operation(summary = "查询同步规则可更新的属性列表")
    @GetMapping("/querySyncRulePropertyList")
    public BaseResponse<List<PropertyConfig>> querySyncRulePropertyList(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                                        @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId,
                                                                        Integer displayLevel) {
        return BaseResponse.success(modelService.querySyncRulePropertyList(projectId, instanceId, displayLevel));
    }

    @Operation(summary = "通过类型查询导入元素属性值(包含多个)")
    @PostMapping("/queryPropertyListByType")
    public BaseResponse<List<PropertyConfig>> queryPropertyListByType(@Valid @RequestBody QueryPropertyByTypeDTO dto) {
        return BaseResponse.success(modelService.queryPropertyListByType(dto));
    }

    @Operation(summary = "查询多种类型的属性值，并进行分组")
    @PostMapping("/queryMultiGroupPropertyListByTypes")
    public BaseResponse<List<MultiGroupPropertyConfigVo>> queryMultiGroupPropertyListByTypes(@Valid @RequestBody QueryPropertyByTypeDTO dto) {
        return BaseResponse.success(modelService.queryMultiGroupPropertyListByTypes(dto));
    }


    @Operation(summary = "查询多种类型的属性值，并进行分组")
    @PostMapping("/queryMultiPropertyListByType")
    public BaseResponse<List<MultiPropertyConfigVo>> queryMultiPropertyListByType(@Valid @RequestBody QueryPropertyByTypeDTO dto) {
        return BaseResponse.success(modelService.queryMultiPropertyListByType(dto));
    }


    @Operation(summary = "根据keys查询模型指定属性值")
    @WebLogIgnore
    @PostMapping("/queryPropertyListByKeys")
    public BaseResponse<List<PropertyConfig>> queryPropertyListBatchByKeys(@Valid @RequestBody QueryPropertyConfigDTO dto) {
        return BaseResponse.success(modelService.queryPropertyListBatchByKeys(dto));
    }

    @Operation(summary = "根据keys查询属于当前模型的属性值")
    @PostMapping("/queryBelongToCurrentInstancePropertyListByKeys")
    public BaseResponse<List<PropertyConfig>> queryBelongToCurrentInstancePropertyListByKeys(@Valid @RequestBody QueryPropertyConfigDTO dto) {
        return BaseResponse.success(modelService.queryBelongToCurrentInstancePropertyListByKeys(dto));
    }

    @Operation(summary = ("批量查询模型属性值"))
    @PostMapping("/queryMutliPropertyValue")
    public BaseResponse<List<MultiPropertyValueVo>> queryMutliPropertyValue(
            @Valid @RequestBody QueryMultiPropertyValueDTO queryMultiPropertyValueDto) {
        ValidateDataUtil.outOfIndex(queryMultiPropertyValueDto.getInstances());
        return BaseResponse.success(modelService.queryTemplateProjectModel(queryMultiPropertyValueDto));
    }

    @Operation(summary = ("批量查询模型属性值v2"))
    @PostMapping("/queryMutliPropertyValue/v2")
    public BaseResponse<List<MultiPropertyValueVo>> queryMutliPropertyValueV2(
            @Valid @RequestBody QueryMultiPropertyValueDTO queryMultiPropertyValueDto) {
        ValidateDataUtil.outOfIndex(queryMultiPropertyValueDto.getInstances());
        return BaseResponse.success(modelService.queryPropertyValueBatch(queryMultiPropertyValueDto));
    }

    /**
     * @deprecated (废弃)
     */
    @Operation(summary = "根据key查询模型指定属性值")
    @GetMapping("/queryPropertyValueByKey")
    @Deprecated
    public BaseResponse<PropertyValueVo> queryPropertyValueByKey(String projectId, String instanceId, String key) {
        return BaseResponse.success(null);
    }

    @Operation(summary = "校验模型类型")
    @GetMapping("/checkType")
    public BaseResponse<Boolean> checkType(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                           @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId,
                                           @NotBlank(message = ParamErrorConstants.NO_TYPE_ID) String typeId) {
        return BaseResponse.success(modelService.checkInstanceType(projectId, instanceId, typeId));
    }

    @Operation(summary = "校验模型类型,支持同时校验多种类型")
    @PostMapping("/checkTypes")
    public BaseResponse<Boolean> checkTypes(@RequestBody CheckTypesDTO checkTypesDTO) {
        return BaseResponse.success(modelService.checkInstanceTypes(checkTypesDTO));
    }

    @Operation(summary = "保存默认值")
    @PostMapping("/saveDefaultValue")
    public BaseResponse<ModelResultVo> saveDefaultValue(
            @Valid @RequestBody SaveDefaultValueDTO saveDefaultValueDto) {
        return BaseResponse.success(modelService.saveDefaultValue(saveDefaultValueDto.getInstanceId(),
                saveDefaultValueDto.getProjectId()));
    }

    @Operation(summary = "获取内部元素")
    @GetMapping("/queryInnerElements")
    public BaseResponse<List<InnerElementVo>> queryInnerElements(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                                 @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.queryInnerElements(projectId, instanceId));
    }

    @Operation(summary = "校验内部元素")
    @PostMapping("/checkInnerElements")
    public BaseResponse<List<CheckShapeDTO>> checkInnerElements(@Valid @RequestBody CheckInnerElementsDTO checkInnerElementsDTO) {
        return BaseResponse.success(modelService.checkInnerElements(checkInnerElementsDTO.getProjectId(), checkInnerElementsDTO.getShape()));
    }

    @Operation(summary = "获取内部端口和部件")
    @GetMapping("/queryInnerPortAndProperty")
    public BaseResponse<List<InnerElementVo>> queryInnerPortAndPartProperty(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                                            @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.queryInnerPortAndProperty(projectId, instanceId));
    }

    @Operation(summary = "批量获取内部端口和部件")
    @GetMapping("/batchQueryInnerPortAndProperty")
    public BaseResponse<List<InnerElementTreeVo>> batchQueryInnerPortAndProperty(@RequestBody QueryInnerPortAndPartPropertyDTO dto) {
        return BaseResponse.success(modelService.batchQueryInnerPortAndProperty(dto));
    }

    @Operation(summary = "粘贴元素")
    @PostMapping("/paste")
    public BaseResponse<CopyResultVo> paste(@Valid @RequestBody CopyDTO dto) {
        return BaseResponse.success(modelService.paste(dto));
    }

    @Operation(summary = "拖动模型库的模型到画布上，创建模型对象")
    @PostMapping("/library/createInstance")
    public BaseResponse<ModelResultVo> createInstance(@Valid @RequestBody CreateModelByLibraryDTO dto) {
        ModelResultVo modelResultVo = modelLibraryService.createInstance(dto);
        if (modelResultVo.getAddModel().isEmpty()) {
            return BaseResponse.error(ErrorCode.MODEL_LIBRARY_NOT_CREATE.getCode(), ErrorCode.MODEL_LIBRARY_NOT_CREATE.getMessage());
        }
        return BaseResponse.success(modelResultVo);
    }

    @Operation(summary = "拖动模型库的关系到画布上")
    @PostMapping("/library/createRelationshipInstance")
    public BaseResponse<ModelResultVo> createRelationshipInstance(@Valid @RequestBody CreateModelByLibraryDTO dto) {
        ModelResultVo modelResultVo = modelLibraryService.createRelationshipInstance(dto);
        if (modelResultVo.getAddModel().isEmpty()) {
            return BaseResponse.error(ErrorCode.MODEL_LIBRARY_NOT_CREATE.getCode(), ErrorCode.MODEL_LIBRARY_NOT_CREATE.getMessage());
        }
        return BaseResponse.success(modelResultVo);
    }

    @Operation(summary = "模型检入")
    @PostMapping("/checkIn")
    public BaseResponse<String> checkIn(@Valid @RequestBody ModelCheckInOutDTO dto) {
        modelService.checkIn(dto);
        return BaseResponse.success(SystemConstants.SUCCESS);
    }

    @Operation(summary = "模型检出")
    @PostMapping("/checkOut")
    public BaseResponse<String> checkOut(@Valid @RequestBody ModelCheckInOutDTO dto) {
        modelService.checkOut(dto);
        return BaseResponse.success(SystemConstants.SUCCESS);
    }

    @Operation(summary = "全量模型检入检出")
    @PostMapping("/checkAll")
    public BaseResponse<String> checkAll(@Valid @RequestBody ModelCheckDTO dto) {
        modelService.checkAll(dto);
        return BaseResponse.success(SystemConstants.SUCCESS);
    }

    @Operation(summary = "获取自定义stereotype对应内置的基本类型")
    @GetMapping("/queryMClassByStereotypeId")
    @WebLogIgnore
    public BaseResponse<String> queryMClassByStereotypeId(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                          @NotBlank(message = ParamErrorConstants.NO_STEREOTYPE_ID) String stereotypeId) {
        return BaseResponse.success(modelService.queryMClassByStereotypeId(projectId, stereotypeId));
    }

    @Operation(summary = "批量获取自定义stereotype对应内置的基本类型")
    @PostMapping("/queryMClassByStereotypeIds")
    //@WebLogIgnore
    public BaseResponse<List<MClassVo>> queryMClassByStereotypeIds(@Valid @RequestBody QueryMClassDTO dto) {
        return BaseResponse.success(modelService.queryMClassByStereotypeIds(dto));
    }

    @Operation(summary = "判断模型是否为指定类型")
    @PostMapping("/checkModelIsTargetType")
    public BaseResponse<List<CheckValidPropertyValueVo>> checkModelIsTargetType(@Valid @RequestBody CheckValidModelTypeDTO dto) {
        return BaseResponse.success(modelService.checkModelIsTargetType(dto));
    }

    @Operation(summary = "判断模型是否为指定类型")
    @GetMapping("/queryPropertyDataType")
    public BaseResponse<String> queryPropertyDataType(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                      @NotBlank(message = ParamErrorConstants.NO_PROPERTY_NAME) String propertyName) {
        return BaseResponse.success(modelService.queryPropertyDataType(projectId, propertyName));
    }


    @Operation(summary = "查询节点下的所有图表")
    @GetMapping("/queryChildDiagram")
    public BaseResponse<List<String>> queryChildDiagram(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                        @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.queryChildDiagram(projectId, instanceId));
    }

    @Operation(summary = "变更指定模型只读属性")
    @PostMapping("/changeReadOnly")
    public BaseResponse<String> changeReadOnly(@Valid @RequestBody UpdateReadOnlyDTO dto) {
        modelService.updateReadOnly(dto);
        return BaseResponse.success(SystemConstants.SUCCESS);
    }

    @Operation(summary = "获取模型是否禁用状态")
    @PostMapping("/getElementDisable")
    public BaseResponse<List<ElementDisableVo>> queryElementDisable(@Valid @RequestBody ModelCheckInOutDTO modelCheckInOutDto) {
        return BaseResponse.success(modelService.queryElementDisable(modelCheckInOutDto.getProjectId(),
                modelCheckInOutDto.getIds()));
    }

    @Operation(summary = "查询所有用户创建模型id")
    @GetMapping("/queryAllUserCreatedInstanceIds")
    public BaseResponse<Set<String>> queryAllUserCreatedInstanceIds(@NotBlank(message =
            ParamErrorConstants.NO_PROJECT_ID) String projectId) {
        return BaseResponse.success(modelService.queryAllUserCreatedInstanceIds(projectId));
    }

    @Operation(summary = "生成密钥对")
    @GetMapping("/generateKeyPair")
    public BaseResponse<KeyPairVo> generateKeyPair() {
        return BaseResponse.success(modelService.generateKeyPair());
    }

    @Operation(summary = "校验项目中是否存在封装模型")
    @GetMapping("/validExistEncryptModel")
    public BaseResponse<String> validExistEncryptModel(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId) {
        return BaseResponse.success(modelService.validExistEncryptModel(projectId));
    }

    @Operation(summary = "校验模型完整性")
    @GetMapping("/validModelIntergrity")
    public BaseResponse<List<LackedModelVo>> validModelIntergrity(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                                  @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.validModelIntergrity(projectId, instanceId));
    }

    @Operation(summary = "封装模型")
    @PostMapping("/encryptModel")
    public BaseResponse<EncryptModelVo> encryptModel(@Valid @RequestBody EncryptModelDTO dto) {
        return BaseResponse.success(modelService.encryptModel(dto));
    }

    @Operation(summary = "解封模型")
    @PostMapping("/decryptModel")
    public BaseResponse<EncryptModelVo> decryptModel(@Valid @RequestBody DecryptModelDTO dto) {
        return BaseResponse.success(modelService.decryptModel(dto));
    }


    @Operation(summary = "查询自定义属性列表")
    @GetMapping("/listSpecificPropertyKeyByClassId")
    public BaseResponse<List<String>> listSpecificPropertyKeyByClassId(@RequestBody ListSpecificInstanceDTO param) {
        return BaseResponse.success(modelService.listSpecificPropertyKeyByClassId(param.getProjectId(), param.getClassfierIds()));
    }


    @Operation(summary = "查询Specific模型列表")
    @GetMapping("/listSpecificInstanceByClassId")
    public BaseResponse<List<InstanceVo>> listSpecificInstanceByClassId(@RequestBody ListSpecificInstanceDTO param) {
        return BaseResponse.success(modelService
                .listSpecificInstanceByClassId(param.getProjectId(), param.getClassfierIds())
                .parallelStream()
                .filter(item -> Objects.equals(item.getFrom(), 3))
                .collect(Collectors.toList()));
    }

    @Operation(summary = "根据构造型获取实例")
    @PostMapping("/querySpecifiedInstanceList")
    public BaseResponse<List<SpecifiedInstanceVo>> querySpecifiedInstanceList(@Valid @RequestBody SpecifiedInstanceDTO dto) {
        return BaseResponse.success(modelService.querySpecifiedVoList(dto.getProjectId(), dto.getTypeId()));
    }

    @Operation(summary = "根据模型类型查询模型实例")
    @GetMapping("/queryInstanceByType")
    public BaseResponse<List<SelectElementItem>> queryInstanceByType(String projectId, String typeId) {
        ValidateDataUtil.isNotEmpty(projectId);
        return BaseResponse.success(modelService.queryInstanceByType(projectId, typeId));
    }

    @Operation(summary = "模型替换/查询被影响模型元素及属性值")
    @GetMapping("/modelReplace/queryAffectModelInfo")
    public BaseResponse<List<SelectAffectElementItem>> queryAffectModelInfo(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                                            @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId) {
        return BaseResponse.success(modelService.queryAffectModelInfo(projectId, instanceId));
    }

    @Operation(summary = "模型替换")
    @PostMapping("/modelReplace/doReplace")
    public BaseResponse<ModelResultVo> replaceModel(@Valid @RequestBody ReplaceModelDTO replaceModelDTO) {
        return BaseResponse.success(modelService.replaceModel(replaceModelDTO));
    }

    @Operation(summary = "查询命名规则")
    @GetMapping("/queryNamingRule")
    public BaseResponse<List<NamingRuleInfo>> queryNamingRule(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId,
                                                              @NotBlank() String parentId) {
        return BaseResponse.success(modelService.queryNamingRule(projectId, parentId));
    }


    @Operation(summary = "模型合并，合并目标模型的属性到源模型")
    @PostMapping("/propertyMergePreview")
    public BaseResponse<List<PropertyMergePreviewVo>> propertyMergePreview(@Valid @RequestBody PropertyMergeDTO propertyMergeDTO) {
        return BaseResponse.success(modelService.propertyMergePreview(propertyMergeDTO));
    }

    @Operation(summary = "模型合并")
    @PostMapping("/propertyMerge")
    public BaseResponse<CopyResultVo> propertyMerge(@Valid @RequestBody PropertyMergeDTO propertyMergeDTO) {
        return BaseResponse.success(modelService.propertyMerge(propertyMergeDTO));
    }

    @Operation(summary = "查询元类通过拓展关系产生的子类，查询构造型通过泛化关系产生的子类")
    @GetMapping("/querySubTypes")
    public BaseResponse<List<ElementType>> querySubTypes(@RequestParam("projectId") String projectId,
                                                         @RequestParam("typeIds") List<String> typeIds,
                                                         @RequestParam("isActualMatch") Boolean isActualMatch) {
        return BaseResponse.success(modelService.querySubTypes(projectId, typeIds, isActualMatch));
    }

    @Operation(summary = "表达式验证接口")
    @PostMapping("/expression/verify")
    public BaseResponse<ExpressionVerifyResultVo> expressionVerify(@Valid @RequestBody ModelExpressionVerifyDTO modelExpressionVerifyDTO) {
        return BaseResponse.success(modelService.expressionVerify(modelExpressionVerifyDTO));
    }
    @Operation(summary = "查询模型含关联属性列表")
    @WebLogIgnore
    @GetMapping("/querySelfAndRelatedPropertyList")
    public BaseResponse<List<PropertyListVo>> querySelfAndRelatedPropertyList(@NotBlank(message = ParamErrorConstants.NO_PROJECT_ID) String projectId, @NotBlank(message = ParamErrorConstants.NO_INSTANCE_ID) String instanceId,Integer displayLevel) {
        return BaseResponse.success(modelService.querySelfAndRelatedPropertyList(projectId, instanceId, displayLevel));
    }
}
